﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Document.aspx.cs" Inherits="Automobile.service.UI.Document" %>



<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>报损报溢</title>
</head>
<body>

    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 库存管理 <span class="c-gray en">&gt;</span> 报损报溢 <a class="btn btn-success radius r mr-20" style="line-height: 1.6em; margin-top: 3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="pd-20">
        <form method="post" action="./Purchase.aspx" id="ctl00">
            <div class="aspNetHidden">
                <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="4jyrlQYaJGS8xq4G0mqcNIusenUzQHcuWwssk+1wl/jRL410Tas5BM34SoznUj/JYRKuKkxkftkdf5SyUVZmGgPK7rTJxSi+fOsjCFN/ighmPot6Z2wDTQYiUBb0gI9j+B5xaQTAvZqC6ubiRDnzOtoXbq4ahoW+8FiGjBgrV/qxRZLgLcMlgwKq5H3ADIkOHjJs9VjRLAk2kxnIvfCsUL+TMF1/1IXUSmAtGb7wiV9raLYFAL5cNprm0y3vkiIA9Ie38dBIjvxK0/XfAu23bkliJV8P0mqknhl/nub5f5GxHumLtPu5b77AGzp5nkwZ7tr21rFVnwUPYAREMzTA7hvw0kLoG8Y9ybMyMmYpN2sgm+1L57/Wh9wIzh+VMeXDUas4QF0OwTIkjNjj96p3OjjYmQ7soql6wQ2J6wq7uxAyns30wxacBUpkZVgowBU0j3PQ0n9NlVsr0hi5roaZhZZkqlRp2VXXfiZC4BsjZID/jmRtLtNwW/mPi1VdpuSL" />
            </div>

            <table class="table table-hover table-bg table-sort">
                <tr>
                    <td>
                        <span>仓库：</span><select name="DropDownList2" id="DropDownList2">
                            <option value="-请选择-">-请选择-</option>
                            <option value="1">A仓库</option>
                            <option value="2">B仓库</option>
                            <option value="3">C仓库</option>
                            <option value="4">D仓库</option>

                        </select>
                        <span>订单类型：</span>
                        <select id="DropDownList3">
                            <option value="0">报损</option>
                            <option value="1">转正</option>
                        </select>
                        <span>备注：</span><input type="text" id="Remark"/>
                    </td>
                </tr>
            </table>
            <div class="aspNetHidden">

                <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="C7C53EDD" />
                <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="aGXsbFGlKIm8aOQC0AdL/HUI0btY+xvJaoCG3vjNlRGgPmOq2IVKrJpd/BfzEeHmDGcfbUvcvxgoNXoVtRVGRVQXeFdW99BEjhy9gpLCdTXUABm/BU3EqodjIzQjqKRLLdbQjMAUX4yV7NnNvb32LQaecU9je+ogphicDHpGpC5SVFRLwU6LwgMhxlyp0eUBVBTszc13D8e7wDA8RmjW1niYwTXqrizF2vEfxrw9MAMZyHgh49RbcNbSB5mdq9zFj3pdf3Jj+Xdgp1dHBr5nuyoxspmxLv/FMkV9Q5a/PlY=" />
            </div>
        </form>
    </div>
    <input type="text" class="input-text" style="width: 250px" placeholder="请输入商品名称" id="ids">
    <button type="submit" class="btn btn-success radius" onclick="fun()"><i class="Hui-iconfont">&#xe665;</i> 搜商品</button>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
                <tr class="text-c">
                    <th width="80">商品编号</th>
                    <th width="80">商品名称</th>
                    <th width="40">商品规格</th>
                    <th width="40">商品价格</th>
                    <th width="100">商品编码</th>
                    <th width="70">库存数量</th>
                    <th width="70">损溢数量</th>
                    <th width="70">金额小计</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <a class="btn btn-primary radius" onclick="Purchase_Add()" style="margin-left: 70px; margin-top: 30px;">确定</a>
        <input type='hidden' value=''id='WareHose_Id'/>
    </div>
    <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="js/H-ui.js"></script>
    <script type="text/javascript" src="js/H-ui.admin.js"></script>
    <script type="text/javascript">
        function fun() {
            if ($("#DropDownList2").val() == "-请选择-") {
                alert("请选择仓库");
                return false;
            }
            $.ajax({
                type: "post",
                url: "Hander/GetProductByName.ashx",
                data: {
                    Product_Name: $("#ids").val(),
                    WareHose_Id: $("#DropDownList2").val()
                },
                success: function (data) {
                    var data1 = eval("(" + data + ")");
                    if (data1 == "") {
                        alert("无此商品");
                    }
                    else {
                        var str = "<tr class='text-c'><td><span name='Product_Id'>" + data1[0].Product_Id + "</span><input name='warehose' type='hidden' value='" + data1[0].WareHose_Id + "'id='WareHose_Id" + data1[0].Product_Id + "'/></td><td>" + data1[0].Product_Name + "</td><td>" + data1[0].Product_Modelspe + "</td><td><span name='Product_Bprid' id='Price" + data1[0].Product_Id + "'>" + data1[0].Product_Bprid + "</span>元</td><td>" + data1[0].Product_Barcode + "</td><td>" + data1[0].Stock_num + "</td><td><input type='text' name='Sum' onchange='Sum(" + data1[0].Product_Id + ")' id='num" + data1[0].Product_Id + "'/></td><td><span name='SumMoney' id='sum" + data1[0].Product_Id + "'>0</span>元</td></tr>";
                        $(".table-border tbody").append(str);
                    }
                }
            })

        }
        //小计
        function Sum(id) {
            var num = $("#num" + id + "").val();
            //正则验证（只能输入正整数）
            var tt = /^\d+$/g;
            if (!tt.test(num)) {
                alert('必须是正整数');
                return false;
            }
            var price = $("#Price" + id + "").text();
            $("#sum" + id + "").text(price * num);
        }
        function Purchase_Add() {

            //获取商品编号
            var d = document.getElementsByName("Product_Id");
            var Product_Id = new Array();
            for (var i = 0; i < d.length; i++) {
                Product_Id[i] = d[i].innerHTML;              
            }

            //获取各个商品的购买数量
            var Sum = new Array();
            var i = -1;
            $("[name='Sum']").each(function () {
                i++;
                Sum[i] = $(this).val();
            })

            //获取商品进价单价
            var a = document.getElementsByName("Product_Bprid");
            var Product_Bprid = new Array();
            for (var i = 0; i < a.length; i++) {
                Product_Bprid[i] = a[i].innerHTML;
            }
            
            //获去各个商品的商品小计
            var c = document.getElementsByName("SumMoney");
            var SumMoney = new Array();
            for (var i = 0; i < c.length; i++) {
                SumMoney[i] = c[i].innerHTML;
            }


            //获取仓库编号
            var ware = new Array();
            var i = -1;
            $("[name='warehose']").each(function () {
                i++;
                ware[i] = $(this).val();
            })
            //字符拼接xml
            var xml = "<xml>";
            for (var i = 0; i < Sum.length; i++) {
                xml += "<product Product_Id='" + Product_Id[i] + "' Document_Mate_Num='" + Sum[i] + "' Document_Mate_Price='" + Product_Bprid[i] + "' Document_Mate_SumPrice='" + SumMoney[i] + "' WareHose_Id='"+ware[i]+"'/>";
            }
            xml += "</xml>";
            var encodexml = encodeURIComponent(xml);// 对xml进行编码
            $.ajax({
                type: "post",
                url: "Hander/SunYi.ashx",
                data: {
                    Document_Type_Id: $("#DropDownList3").val(),
                    Document_Remark: $("#Remark").val(),
                    xml: encodexml
                },
                success: function (data) {
                    if (data > 0) {
                        alert("操作成功");
                    }
                },
                error: function () {
                    alert("服务器忙");
                }
            })
        }

    </script>


    <!-- Visual Studio Browser Link -->
    <script type="application/json" id="__browserLink_initializationData">
    {"appName":"Firefox","requestId":"74621ea201e7434c98c5025958eed5b5"}
    </script>
    <script type="text/javascript" src="http://localhost:3735/a8ff0a3a06704999a10fc6cfdd5f98f1/browserLink" async="async"></script>
    <!-- End Browser Link -->

</body>
</html>



